﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using MVCTippSpielManagement.Utilities;
using System.Configuration;

namespace MVCTippSpielManagement.Management
{
	public class MyApplication
	{

		#region Applications values
		public User _LogOnUser;

		protected RightsManager _RightsManager;
		protected UserMenu _UserMenuEntries;

						
		#endregion

		#region Singleton Pattern
		protected static MyApplication _Instance = null;
		protected static Object mLock = new Object();

		public static MyApplication Instance
		{
			get
			{
				if (_Instance == null)
				{
					lock (mLock)
					{
						if (_Instance == null)
						{
							_Instance = new MyApplication();
						}
					}
				}
				return _Instance;
			}
		}

		private MyApplication()
		{

			string XMLUser;

			// Create LogUserObject 
			AppSettingsReader asr = new AppSettingsReader();
			XMLUser = (string)asr.GetValue("LogOnUser", typeof(string));
			_LogOnUser = new LogOnUser(XMLUser);
			
			// Menü laden (Alle Einträge aus der XML-Datei)
			_RightsManager = new RightsManager();
			
			//Applikationseintellungen laden
			_UserMenuEntries = _RightsManager.GetUserMenu(_LogOnUser);



		}
		#endregion

		public UserMenu UserMenuEntries
		{
			get { return _UserMenuEntries; }
		}

	}
}
